Skip to content

feat(spp_mis_demo_v2): add child/spouse/other membership types#165

Open
emjay0921 wants to merge 1 commit into19.0from
feat/922-mis-demo-membership-types
Open

feat(spp_mis_demo_v2): add child/spouse/other membership types#165
emjay0921 wants to merge 1 commit into19.0from
feat/922-mis-demo-membership-types

Conversation

@emjay0921
Copy link
Copy Markdown
Contributor

Why is this change needed?

OpenProject #922 — spp_mis_demo_v2 should populate group-membership-type on every household membership so the demo data realistically exercises the vocabulary. Before this change, only head was assigned; spouse/adult/child members had no type at all, and a demo change-request referenced a non-existent xmlid (spp_registry.group_membership_kind_child).

How was the change implemented?

  • New demo vocabulary dataspp_mis_demo_v2/data/vocabulary_group_membership_type.xml registers child, spouse, other codes against the existing vocab_group_membership_type vocabulary. Scoped to the demo module (not spp_vocabulary) so core stays non-prescriptive about household composition.

  • Blueprint roles drive type assignment. The existing story blueprints and seeded blueprints already encode demographically-correct gender and age ranges (child ≤ 17 in most cases, adult spouse opposite-gender to head, etc.). The generator just maps role → membership type:

    Blueprint role Membership type
    head head
    spouse spouse
    child child
    adult, elderly other
  • seeded_volume_generator.py — replaced _get_head_type_id with a cached _get_membership_type_id(code); assigns per-role.

  • mis_demo_generator.py — applies the mapping in _create_household_members for spouse, adults, and children (head already had it); also fixed the stale xmlid on the carlos_elena_morales add_member demo change request.

New unit tests

  • test_non_head_members_have_membership_types — asserts every generated membership carries exactly one of {head, spouse, child, other}, at most one spouse per household, and child members are younger than the head.

Unit tests executed by the author

Full spp_mis_demo_v2 suite (270 tests, Docker): 0 failed on my changes. The only errors (3) are pre-existing test_claim169_demo FK issues on res_partner_bank, unrelated to this PR.

How to test manually

  1. Install/upgrade spp_mis_demo_v2 on a fresh DB.
  2. Open any demo household (Bautista, Navarro, Morales, etc.).
  3. On the Membership tab every member should show a type tag: one Head, optionally one Spouse, zero or more Child, with the rest as Other.
  4. Verify the "Add newborn to Morales household" demo CR (CR about Baby Morales) has a valid Relationship value instead of erroring on a missing xmlid.

Related links

Enable the child, spouse, and other group-membership-type vocabulary
codes inside the demo module and apply them when generating households.
The existing blueprint roles already honor gender and age ranges, so
the generator assigns membership types from those roles:

  head   -> head
  spouse -> spouse
  child  -> child
  adult, elderly -> other

Fix a stale reference to spp_registry.group_membership_kind_child in
the add_member change-request demo data; point it to the new xmlid.

The types are scoped to spp_mis_demo_v2 (not spp_vocabulary) so that
core stays non-prescriptive about household composition.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.61%. Comparing base (b061135) to head (63c6e34).

Files with missing lines Patch % Lines
spp_mis_demo_v2/models/seeded_volume_generator.py 93.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #165      +/-   ##
==========================================
+ Coverage   71.45%   71.61%   +0.16%     
==========================================
  Files         932      933       +1     
  Lines       54792    55318     +526     
==========================================
+ Hits        39152    39618     +466     
- Misses      15640    15700      +60     
Flag Coverage Δ
spp_base_common 90.26% <ø> (ø)
spp_dci_demo 69.23% <ø> (ø)
spp_mis_demo_v2 74.30% <95.65%> (+4.29%) ⬆️
spp_programs 64.33% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_mis_demo_v2/__manifest__.py 0.00% <ø> (ø)
spp_mis_demo_v2/models/mis_demo_generator.py 68.59% <100.00%> (+2.66%) ⬆️
spp_mis_demo_v2/models/seeded_volume_generator.py 94.28% <93.33%> (-1.06%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces structured membership types (head, spouse, child, and other) for household members within the demo data generator. Key changes include the definition of new vocabulary codes, updates to the mis_demo_generator and seeded_volume_generator to assign these types based on member roles, and the addition of a test case to verify correct assignment and basic business logic. One improvement was suggested to use the modern Odoo Command helper instead of legacy tuple syntax for Many2many field operations in the seeded volume generator.


type_id = self._get_membership_type_id(type_code)
if type_id:
mval["membership_type_ids"] = [(4, type_id)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the Command helper is preferred over the legacy tuple syntax (4, id) for Many2many fields in modern Odoo versions.

Suggested change
mval["membership_type_ids"] = [(4, type_id)]
mval["membership_type_ids"] = [Command.link(type_id)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant